import 'package:flutter/material.dart';
import 'package:flutterdemo01/demo3/pages/FirstNewsListPage.dart';

main() {
  // runApp(DemoApp());
  runApp(DemoApp2());
}


class DemoApp2 extends StatelessWidget {
  // const DemoApp2({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: {
        '/mlist':(context)=>FirstNewsListPage(),

      },

      theme: ThemeData(primaryColor: Colors.green),
      home: Scaffold(

        body: TApp(),

      ),
    );
  }
}

class TApp extends StatefulWidget {
  const TApp({Key? key}) : super(key: key);

  @override
  _TAppState createState() => _TAppState();
}

class _TAppState extends State<TApp> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(

        children: [
          SizedBox(height: 200,),
          ElevatedButton(onPressed: (){

            // Navigator.of(context).push(
            //   MaterialPageRoute(builder: (context){ return FirstNewsListPage();}),
            // );

            Navigator.pushNamed(context, '/mlist');
          }, child: Text('按钮'))
        ],
      ),
    );
  }
}



// class DemoApp2 extends StatefulWidget {
//   const DemoApp2({Key? key}) : super(key: key);
//
//   @override
//   _DemoApp2State createState() => _DemoApp2State();
// }
//
// class _DemoApp2State extends State<DemoApp2> {
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(
//       routes: {
//         '/mlist':(context)=> FirstNewsListPage(),
//         },
//
//       theme: ThemeData(primaryColor: Colors.green),
//       home: Scaffold(
//           body: Column(
//         children: [
//           SizedBox(
//             height: 100,
//           ),
//           ElevatedButton(
//             onPressed: () {
//               // Navigator.of(context).push(MaterialPageRoute(builder: (context) {
//               //   return FirstNewsListPage();
//               // }));
//               Navigator.pushNamed(context, '/mlist');
//             },
//             child: Text('点击'),
//           ),
//         ],
//       )),
//     );
//   }
// }
